package me.zhengjie.org.employeechange.repository;

import me.zhengjie.org.employeechange.domain.EmployeeChange;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;

/**
* @author ZGZ
* @date 2020-04-14
*/
public interface EmployeeChangeRepository extends JpaRepository<EmployeeChange, Integer>, JpaSpecificationExecutor<EmployeeChange> {
    @Transactional(rollbackFor = Exception.class)
    @Modifying
    @Query(value = "INSERT INTO employee_change(emp_id,from_center_id,to_center_id,change_time,`describe`) Values(?1,?2,?3,?4,?5)",nativeQuery = true)
    void insertEmployeeChange(Integer emp_id, Integer from_center_id,Integer to_center_id,Timestamp change_time,String describe);
}